package org.gesplan.ui;

import java.awt.Dimension;
import java.awt.Toolkit;
import java.beans.PropertyVetoException;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFrame;
import javax.swing.JInternalFrame;
import javax.swing.JOptionPane;
import org.gesplan.entity.Work;
import org.gesplan.util.ExcelManager;
import org.gesplan.util.ReportManager;
import org.gesplan.util.Utils;


/**
 *
 * @author David
 */
public class MDIApplication extends JFrame {

    private ResourceBundle bundle;
    private Logger logger;


    public MDIApplication() {
    	
        bundle = Utils.getBundle();
        logger = Utils.getLogger();
        try {
            initComponents();
        } catch (Exception e) {
            JOptionPane.showMessageDialog(this, bundle.getString("ERROR_DB_CONNECTION"), "Error MDI", JOptionPane.ERROR_MESSAGE);
            logger.log(Level.SEVERE, bundle.getString("ERROR_DB_CONNECTION"), e);
            System.exit(-1);
        }
        initConfig();
        Utils.setLoaded();
        logger.info("Opening application");
        
    }


    private void initConfig() {
    	
        Dimension pantalla = Toolkit.getDefaultToolkit().getScreenSize();
        this.setBounds(100, 50, pantalla.width - 200, pantalla.height - 100);
        this.setResizable(true);
        setExtendedState(MDIApplication.MAXIMIZED_BOTH);
        desktopPane.setBounds(0, 0, pantalla.width, pantalla.height - 20);
        this.setTitle(bundle.getString("TITLE_FORM"));
		String versionCode = MainClass.class.getPackage().getImplementationVersion();
		if (versionCode != null){
			versionLabel.setText("Versió: "+versionCode);
		}
        
    }


    public void manageFrames(JInternalFrame frame) {
        frame.setVisible(true);
        try {
            frame.setSelected(true);
        } catch (PropertyVetoException ex) {
            logger.severe(ex.getMessage());
        }
    }


    public WorkAddFrame openWorkFrame(String serviceId, String serviceDescription) {
        final WorkAddFrame comunicat = new WorkAddFrame(serviceId, serviceDescription);
        open(comunicat);
        return comunicat;        
    }


    public WorkAddFrame openWorkFrame(Work work, String action, String dummy) {
        final WorkAddFrame comunicat = new WorkAddFrame(work, action);
        open(comunicat);
        return comunicat;
    }


    private void open(final JInternalFrame comunicat) {
    	
        comunicat.setVisible(true);
        comunicat.setClosable(true);
        comunicat.setIconifiable(true);
        comunicat.setResizable(true);
        Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
        int w = comunicat.getSize().width;
        int h = comunicat.getSize().height;
        int x = (dim.width - w) / 2;
        int y = (dim.height - h) / 2;
        comunicat.setLocation(x + 180, y - 80);
        java.awt.EventQueue.invokeLater(new Runnable() {
            @Override
            public void run() {
                comunicat.toFront();
                comunicat.repaint();
            }
        });
        desktopPane.add(comunicat);
        
    }


    private void closeApp() {
        logger.info("Closing application");
        System.exit(0);
    }


    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        desktopPane = new javax.swing.JDesktopPane();
        staffInternalFrame = new org.gesplan.ui.StaffFrame();
        materialInternalFrame = new org.gesplan.ui.MaterialFrame();
        materialBuildingFrame = new org.gesplan.ui.MaterialBuildingFrame();
        workFrame = new org.gesplan.ui.WorkFrame();
        rptStaffHoursFrame = new org.gesplan.ui.RptStaffHoursFrame();
        statusPanel = new javax.swing.JPanel();
        commonProgressBar = new javax.swing.JProgressBar();
        versionLabel = new javax.swing.JLabel();
        validationLabel = new javax.swing.JLabel();
        currentLabel = new javax.swing.JLabel();
        totalLabel = new javax.swing.JLabel();
        menuBar = new javax.swing.JMenuBar();
        windowMenu = new javax.swing.JMenu();
        staffMenuItem = new javax.swing.JMenuItem();
        materialMenuItem = new javax.swing.JMenuItem();
        buildingMenuItem = new javax.swing.JMenuItem();
        workMenuItem = new javax.swing.JMenuItem();
        StaffHoursMenuItem = new javax.swing.JMenuItem();
        workMenu = new javax.swing.JMenu();
        ComunicatJardineriaMenuItem = new javax.swing.JMenuItem();
        ComunicatForestalMenuItem = new javax.swing.JMenuItem();
        ComunicatEnllumenatMenuItem = new javax.swing.JMenuItem();
        ComunicatClavegueramMenuItem = new javax.swing.JMenuItem();
        ComunicatViaPublicaMenuItem = new javax.swing.JMenuItem();
        ComunicatEdificisMenuItem = new javax.swing.JMenuItem();
        ComunicatSenyalitacioMenuItem = new javax.swing.JMenuItem();
        ComunicatNoProductivesMenuItem = new javax.swing.JMenuItem();
        reportsMenu = new javax.swing.JMenu();
        rptStaffMenuItem = new javax.swing.JMenuItem();
        jMenuItem1 = new javax.swing.JMenuItem();
        jMenuItem2 = new javax.swing.JMenuItem();
        jMenuItem3 = new javax.swing.JMenuItem();
        detailHoursMenuItem = new javax.swing.JMenuItem();
        materialsBuildingMenuItem = new javax.swing.JMenuItem();
        materialsListMenuItem = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                formWindowClosing(evt);
            }
        });

        staffInternalFrame.setMaximizable(true);
        staffInternalFrame.setResizable(true);
        staffInternalFrame.setVisible(false);
        staffInternalFrame.setBounds(370, 110, 682, 580);
        desktopPane.add(staffInternalFrame, javax.swing.JLayeredPane.DEFAULT_LAYER);

        materialInternalFrame.setMaximizable(true);
        materialInternalFrame.setResizable(true);
        materialInternalFrame.setVisible(false);
        materialInternalFrame.setBounds(20, 10, 860, 730);
        desktopPane.add(materialInternalFrame, javax.swing.JLayeredPane.DEFAULT_LAYER);

        materialBuildingFrame.setMaximizable(true);
        materialBuildingFrame.setVisible(false);
        materialBuildingFrame.setBounds(120, 40, 640, 690);
        desktopPane.add(materialBuildingFrame, javax.swing.JLayeredPane.DEFAULT_LAYER);

        workFrame.setDefaultCloseOperation(javax.swing.WindowConstants.HIDE_ON_CLOSE);
        workFrame.setIconifiable(true);
        workFrame.setMaximizable(true);
        workFrame.setResizable(true);
        workFrame.setTitle("Consulta comunicats de treball");
        workFrame.setVisible(true);
        workFrame.setBounds(150, 10, 830, 670);
        desktopPane.add(workFrame, javax.swing.JLayeredPane.DEFAULT_LAYER);

        rptStaffHoursFrame.setVisible(true);
        rptStaffHoursFrame.setBounds(220, 20, 834, 551);
        desktopPane.add(rptStaffHoursFrame, javax.swing.JLayeredPane.DEFAULT_LAYER);

        statusPanel.setBackground(new java.awt.Color(204, 204, 204));

        commonProgressBar.setMaximum(10000);

        versionLabel.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        versionLabel.setText(bundle.getString("VERSION")); // NOI18N
        versionLabel.setVerticalAlignment(javax.swing.SwingConstants.TOP);

        validationLabel.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        validationLabel.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
        validationLabel.setToolTipText("");
        validationLabel.setVerticalAlignment(javax.swing.SwingConstants.TOP);

        currentLabel.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);

        javax.swing.GroupLayout statusPanelLayout = new javax.swing.GroupLayout(statusPanel);
        statusPanel.setLayout(statusPanelLayout);
        statusPanelLayout.setHorizontalGroup(
            statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, statusPanelLayout.createSequentialGroup()
                .addGap(18, 18, 18)
                .addComponent(currentLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(totalLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 249, Short.MAX_VALUE)
                .addComponent(validationLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 230, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(commonProgressBar, javax.swing.GroupLayout.PREFERRED_SIZE, 215, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(54, 54, 54)
                .addComponent(versionLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        statusPanelLayout.setVerticalGroup(
            statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(statusPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(totalLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addComponent(commonProgressBar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(versionLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(validationLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(currentLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        windowMenu.setMnemonic('F');
        windowMenu.setText(bundle.getString("MENU_WINDOW")); // NOI18N
        windowMenu.setToolTipText("");

        staffMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_W, java.awt.event.InputEvent.ALT_MASK));
        staffMenuItem.setMnemonic('T');
        staffMenuItem.setText(bundle.getString("STAFF")); // NOI18N
        staffMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                staffMenuItemActionPerformed(evt);
            }
        });
        windowMenu.add(staffMenuItem);

        materialMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_M, java.awt.event.InputEvent.ALT_MASK));
        materialMenuItem.setMnemonic('M');
        materialMenuItem.setText("Material");
        materialMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                materialMenuItemActionPerformed(evt);
            }
        });
        windowMenu.add(materialMenuItem);

        buildingMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_E, java.awt.event.InputEvent.ALT_MASK));
        buildingMenuItem.setMnemonic('E');
        buildingMenuItem.setText("Edificis - Materials");
        buildingMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buildingMenuItemActionPerformed(evt);
            }
        });
        windowMenu.add(buildingMenuItem);

        workMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_B, java.awt.event.InputEvent.ALT_MASK));
        workMenuItem.setMnemonic('b');
        workMenuItem.setText(bundle.getString("WORK")); // NOI18N
        workMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                workMenuItemActionPerformed(evt);
            }
        });
        windowMenu.add(workMenuItem);

        StaffHoursMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_U, java.awt.event.InputEvent.ALT_MASK));
        StaffHoursMenuItem.setMnemonic('u');
        StaffHoursMenuItem.setText("Resum treballadors");
        StaffHoursMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                StaffHoursMenuItemActionPerformed(evt);
            }
        });
        windowMenu.add(StaffHoursMenuItem);

        menuBar.add(windowMenu);

        workMenu.setMnemonic('C');
        workMenu.setText("Comunicat de treball");

        ComunicatJardineriaMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_1, java.awt.event.InputEvent.ALT_MASK));
        ComunicatJardineriaMenuItem.setText("Jardineria");
        ComunicatJardineriaMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ComunicatJardineriaMenuItemActionPerformed(evt);
            }
        });
        workMenu.add(ComunicatJardineriaMenuItem);

        ComunicatForestalMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_2, java.awt.event.InputEvent.ALT_MASK));
        ComunicatForestalMenuItem.setText("Forestal");
        ComunicatForestalMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ComunicatForestalMenuItemActionPerformed(evt);
            }
        });
        workMenu.add(ComunicatForestalMenuItem);

        ComunicatEnllumenatMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_3, java.awt.event.InputEvent.ALT_MASK));
        ComunicatEnllumenatMenuItem.setText("Enllumenat");
        ComunicatEnllumenatMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ComunicatEnllumenatMenuItemActionPerformed(evt);
            }
        });
        workMenu.add(ComunicatEnllumenatMenuItem);

        ComunicatClavegueramMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_4, java.awt.event.InputEvent.ALT_MASK));
        ComunicatClavegueramMenuItem.setText("Clavegueram");
        ComunicatClavegueramMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ComunicatClavegueramMenuItemActionPerformed(evt);
            }
        });
        workMenu.add(ComunicatClavegueramMenuItem);

        ComunicatViaPublicaMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_5, java.awt.event.InputEvent.ALT_MASK));
        ComunicatViaPublicaMenuItem.setText("Via pública");
        ComunicatViaPublicaMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ComunicatViaPublicaMenuItemActionPerformed(evt);
            }
        });
        workMenu.add(ComunicatViaPublicaMenuItem);

        ComunicatEdificisMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_6, java.awt.event.InputEvent.ALT_MASK));
        ComunicatEdificisMenuItem.setText("Edificis");
        ComunicatEdificisMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ComunicatEdificisMenuItemActionPerformed(evt);
            }
        });
        workMenu.add(ComunicatEdificisMenuItem);

        ComunicatSenyalitacioMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_7, java.awt.event.InputEvent.ALT_MASK));
        ComunicatSenyalitacioMenuItem.setText("Senyalització i codi");
        ComunicatSenyalitacioMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ComunicatSenyalitacioMenuItemActionPerformed(evt);
            }
        });
        workMenu.add(ComunicatSenyalitacioMenuItem);

        ComunicatNoProductivesMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_8, java.awt.event.InputEvent.ALT_MASK));
        ComunicatNoProductivesMenuItem.setText("No productives");
        ComunicatNoProductivesMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ComunicatNoProductivesMenuItemActionPerformed(evt);
            }
        });
        workMenu.add(ComunicatNoProductivesMenuItem);

        menuBar.add(workMenu);

        reportsMenu.setMnemonic('I');
        reportsMenu.setText(bundle.getString("MENU_REPORTS")); // NOI18N

        rptStaffMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_T, java.awt.event.InputEvent.ALT_MASK | java.awt.event.InputEvent.CTRL_MASK));
        rptStaffMenuItem.setMnemonic('S');
        rptStaffMenuItem.setText(bundle.getString("STAFF")); // NOI18N
        rptStaffMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rptStaffMenuItemActionPerformed(evt);
            }
        });
        reportsMenu.add(rptStaffMenuItem);

        jMenuItem1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_M, java.awt.event.InputEvent.ALT_MASK | java.awt.event.InputEvent.CTRL_MASK));
        jMenuItem1.setText("Hores mensuals secció");
        jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem1ActionPerformed(evt);
            }
        });
        reportsMenu.add(jMenuItem1);

        jMenuItem2.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_R, java.awt.event.InputEvent.ALT_MASK | java.awt.event.InputEvent.CTRL_MASK));
        jMenuItem2.setText("Resum anual");
        jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem2ActionPerformed(evt);
            }
        });
        reportsMenu.add(jMenuItem2);

        jMenuItem3.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_L, java.awt.event.InputEvent.ALT_MASK | java.awt.event.InputEvent.CTRL_MASK));
        jMenuItem3.setText("Resum mensual");
        jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem3ActionPerformed(evt);
            }
        });
        reportsMenu.add(jMenuItem3);

        detailHoursMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_U, java.awt.event.InputEvent.ALT_MASK | java.awt.event.InputEvent.CTRL_MASK));
        detailHoursMenuItem.setText("Detall hores");
        detailHoursMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                detailHoursMenuItemActionPerformed(evt);
            }
        });
        reportsMenu.add(detailHoursMenuItem);

        materialsBuildingMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_E, java.awt.event.InputEvent.ALT_MASK | java.awt.event.InputEvent.CTRL_MASK));
        materialsBuildingMenuItem.setText("Materials per edifici");
        materialsBuildingMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                materialsBuildingMenuItemActionPerformed(evt);
            }
        });
        reportsMenu.add(materialsBuildingMenuItem);

        materialsListMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F, java.awt.event.InputEvent.ALT_MASK | java.awt.event.InputEvent.CTRL_MASK));
        materialsListMenuItem.setText("Materials per família");
        materialsListMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                materialsListMenuItemActionPerformed(evt);
            }
        });
        reportsMenu.add(materialsListMenuItem);

        menuBar.add(reportsMenu);

        setJMenuBar(menuBar);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(desktopPane)
            .addComponent(statusPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(desktopPane, javax.swing.GroupLayout.DEFAULT_SIZE, 765, Short.MAX_VALUE)
                .addGap(1, 1, 1)
                .addComponent(statusPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        getAccessibleContext().setAccessibleDescription("");

        pack();
    }// </editor-fold>//GEN-END:initComponents


    private void staffMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_staffMenuItemActionPerformed
        manageFrames(staffInternalFrame);
    }//GEN-LAST:event_staffMenuItemActionPerformed

    private void materialMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_materialMenuItemActionPerformed
        manageFrames(materialInternalFrame);
    }//GEN-LAST:event_materialMenuItemActionPerformed

    private void rptStaffMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rptStaffMenuItemActionPerformed
        ReportManager.execReport("report1");
    }//GEN-LAST:event_rptStaffMenuItemActionPerformed

    private void ComunicatJardineriaMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ComunicatJardineriaMenuItemActionPerformed
        openWorkFrame("jar", "Jardineria");
    }//GEN-LAST:event_ComunicatJardineriaMenuItemActionPerformed

    private void ComunicatForestalMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ComunicatForestalMenuItemActionPerformed
        openWorkFrame("for", "Forestal");
    }//GEN-LAST:event_ComunicatForestalMenuItemActionPerformed

    private void ComunicatEnllumenatMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ComunicatEnllumenatMenuItemActionPerformed
        openWorkFrame("enl", "Enllumenat");
    }//GEN-LAST:event_ComunicatEnllumenatMenuItemActionPerformed

    private void ComunicatClavegueramMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ComunicatClavegueramMenuItemActionPerformed
        openWorkFrame("cla", "Clavegueram");
    }//GEN-LAST:event_ComunicatClavegueramMenuItemActionPerformed

    private void ComunicatViaPublicaMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ComunicatViaPublicaMenuItemActionPerformed
        openWorkFrame("via", "Via pública");
    }//GEN-LAST:event_ComunicatViaPublicaMenuItemActionPerformed

    private void ComunicatEdificisMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ComunicatEdificisMenuItemActionPerformed
        openWorkFrame("edi", "Edificis");
    }//GEN-LAST:event_ComunicatEdificisMenuItemActionPerformed

    private void ComunicatSenyalitacioMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ComunicatSenyalitacioMenuItemActionPerformed
        openWorkFrame("sen", "Senyalització i codi");
    }//GEN-LAST:event_ComunicatSenyalitacioMenuItemActionPerformed

    private void workMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_workMenuItemActionPerformed
        manageFrames(workFrame);
    }//GEN-LAST:event_workMenuItemActionPerformed

    private void ComunicatNoProductivesMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ComunicatNoProductivesMenuItemActionPerformed
        openWorkFrame("vac", "No productives");
    }//GEN-LAST:event_ComunicatNoProductivesMenuItemActionPerformed

    private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
        closeApp();
    }//GEN-LAST:event_formWindowClosing

    private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
        ExcelManager.reportMonthSection();
    }//GEN-LAST:event_jMenuItem1ActionPerformed

    private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed
        ExcelManager.reportAnnual();
    }//GEN-LAST:event_jMenuItem2ActionPerformed

    private void buildingMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buildingMenuItemActionPerformed
        manageFrames(materialBuildingFrame);
    }//GEN-LAST:event_buildingMenuItemActionPerformed

    private void StaffHoursMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_StaffHoursMenuItemActionPerformed
        manageFrames(rptStaffHoursFrame);
    }//GEN-LAST:event_StaffHoursMenuItemActionPerformed

    private void detailHoursMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_detailHoursMenuItemActionPerformed
        ExcelManager.reportWork(null);
    }//GEN-LAST:event_detailHoursMenuItemActionPerformed

    private void materialsBuildingMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_materialsBuildingMenuItemActionPerformed
        ExcelManager.reportMaterialsBuilding(null, null, null);
    }//GEN-LAST:event_materialsBuildingMenuItemActionPerformed

    private void materialsListMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_materialsListMenuItemActionPerformed
        ExcelManager.reportMaterialsList(null);
    }//GEN-LAST:event_materialsListMenuItemActionPerformed

    private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem3ActionPerformed
        ExcelManager.reportMonthly();
    }//GEN-LAST:event_jMenuItem3ActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenuItem ComunicatClavegueramMenuItem;
    private javax.swing.JMenuItem ComunicatEdificisMenuItem;
    private javax.swing.JMenuItem ComunicatEnllumenatMenuItem;
    private javax.swing.JMenuItem ComunicatForestalMenuItem;
    private javax.swing.JMenuItem ComunicatJardineriaMenuItem;
    private javax.swing.JMenuItem ComunicatNoProductivesMenuItem;
    private javax.swing.JMenuItem ComunicatSenyalitacioMenuItem;
    private javax.swing.JMenuItem ComunicatViaPublicaMenuItem;
    private javax.swing.JMenuItem StaffHoursMenuItem;
    private javax.swing.JMenuItem buildingMenuItem;
    public javax.swing.JProgressBar commonProgressBar;
    public javax.swing.JLabel currentLabel;
    private javax.swing.JDesktopPane desktopPane;
    private javax.swing.JMenuItem detailHoursMenuItem;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JMenuItem jMenuItem3;
    public org.gesplan.ui.MaterialBuildingFrame materialBuildingFrame;
    private org.gesplan.ui.MaterialFrame materialInternalFrame;
    private javax.swing.JMenuItem materialMenuItem;
    private javax.swing.JMenuItem materialsBuildingMenuItem;
    private javax.swing.JMenuItem materialsListMenuItem;
    private javax.swing.JMenuBar menuBar;
    private javax.swing.JMenu reportsMenu;
    private org.gesplan.ui.RptStaffHoursFrame rptStaffHoursFrame;
    private javax.swing.JMenuItem rptStaffMenuItem;
    private org.gesplan.ui.StaffFrame staffInternalFrame;
    private javax.swing.JMenuItem staffMenuItem;
    private javax.swing.JPanel statusPanel;
    public javax.swing.JLabel totalLabel;
    public javax.swing.JLabel validationLabel;
    private javax.swing.JLabel versionLabel;
    private javax.swing.JMenu windowMenu;
    private org.gesplan.ui.WorkFrame workFrame;
    private javax.swing.JMenu workMenu;
    private javax.swing.JMenuItem workMenuItem;
    // End of variables declaration//GEN-END:variables
}